import Vue from 'vue'
import Vuex from 'vuex'
//1.导入插件
import VuexPersistence from 'vuex-persist'
//2. 创建对象进行配置
//配置存储介质，默认持久化到本地存储中
const vuexLocal = new VuexPersistence({
  storage: window.localStorage,
})

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    unfinish:[],
    completed:[],
    canceled:[]
  },
  mutations: {
    //添加到未完成
    search(state,dats){
      state.unfinish.push(dats)
    },
    //添加到已完成
    addy(state,index){
      state.completed.push(index)
      state.unfinish.splice(index,1)
    },
    //点击取消
    delq(state,index){
      state.canceled.push(index)
      state.unfinish.splice(index,1)
    },
    //点击恢复
    recover(state,index){
      state.unfinish.push(index)
      state.canceled.splice(index,1)
    },
    //点击添加到未完成
    cwy(state,index){
      state.unfinish.push(index)
      state.completed.splice(index,1)
    }

  },
  actions: {},
  getters: {

  },
  modules: {},

  plugins: [vuexLocal.plugin],//引入插件
})
